package com.servlet;

import com.service.QRService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by ztc on 16-3-21.下午4:13
 */
public class QRSiginIn extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uuid=request.getParameter("uuid");
        String teacherID=request.getParameter("teacherID");
        String stuID=request.getParameter("stuID");
        String stuName=request.getParameter("stuName");
        String ip=request.getRemoteAddr();
        String name=request.getRemoteHost();

        QRService service=new QRService();
        if(service.isUuid(uuid)) {
            if (service.signIn(uuid, stuID, stuName, ip, name)) {
                request.setAttribute("flag", "true");
                request.getRequestDispatcher("/qrresult.jsp").forward(request, response);
            }
        }
        request.setAttribute("flag", "false");
        request.getRequestDispatcher("/qrresult.jsp").forward(request, response);
    }
}
